package com.bins.dentist.clinic.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bins.dentist.clinic.model.dto.PatientDto;
import com.bins.dentist.clinic.model.dto.PatientPageDto;
import com.bins.dentist.clinic.model.vo.PatientVo;
import com.bins.dentist.clinic.model.vo.ResultVo;
import com.bins.dentist.clinic.model.vo.SimpleSelectVo;
import com.bins.dentist.clinic.service.PatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author bins
 * @since 2023-04-23 13:22:37
 */
@RestController
@RequestMapping("/patient")
public class PatientController {

    @Autowired
    private PatientService patientService;

    @GetMapping("/page")
    public ResultVo<IPage<PatientVo>> pageList(PatientPageDto pageDto) {
        return ResultVo.ok().data(patientService.getPage(pageDto));
    }

    @GetMapping("/detail")
    public ResultVo<PatientVo> detail(PatientDto dto) {
        return ResultVo.ok().data(patientService.getDetail(dto));
    }

    @PostMapping("/save")
    public ResultVo<PatientVo> savePatient(@RequestBody PatientDto dto) {
        return ResultVo.ok().data(patientService.savePatient(dto));
    }

    @PostMapping("/delete")
    public ResultVo<Integer> deletePatient(@RequestBody PatientDto dto){
        return ResultVo.ok().data(patientService.deletePatient(dto));
    }

    @GetMapping("/select")
    public ResultVo<List<SimpleSelectVo>> selectList(PatientDto dto) {
        return ResultVo.ok().data(patientService.selectList(dto));
    }

}

